﻿namespace dPet.Domain.Services.Implementation
{
	using dPet.Domain.Models;
	using dPet.Domain.Repositories;
	using Hangerd;

	public class AccountDomainService : IAccountDomainService
	{
		private readonly IStaffRepository _staffRepository;

		public AccountDomainService(IStaffRepository staffRepository)
		{
			_staffRepository = staffRepository;
		}

		public Staff RegisterNewStaff(Hospital hospital, StaffRole staffRole, string loginName, string unencryptedPassword, string name, string contact)
		{
			if (_staffRepository.ExistLoginName(loginName))
			{
				throw new HangerdException("登录名已存在");
			}

			return  new Staff(hospital, loginName, unencryptedPassword, staffRole)
			{
				Name = name,
				Contact = contact
			};
		}
	}
}
